Matrix

A 2D matrix of floating-point values.

Matrix.add(m1, m2)
Arguments:
Return type:

Matrix

Adds two matrices of the same size.

Matrix.addConstant(matrix, value)
Arguments:
  • matrix (Matrix)

  • value (float)

Adds the value to each matrix element.

Matrix.clone(matrix)
Argument:
Return type:

Matrix

Duplicates the matrix.

Matrix.concatenate(m1, m2, concatHorizontally)
Arguments:
Return type:

Matrix

Returns the concatenation of the two matrices.

Matrix.create(rows, cols)
Arguments:
  • rows (int)

  • cols (int)

Return type:

Matrix

Creates a new matrix.

Matrix.createFromVector(vector, rows, cols)
Arguments:
  • vector (float)

  • rows (int)

  • cols (int)

Return type:

Matrix

Creates a new matrix from a vector in row-major order.

Matrix.createIdentity(size)
Argument:
  • size (int)

Return type:

Matrix

Creates a new identity matrix.

Matrix.determinant(matrix)
Argument:
Return type:

float

Returns the determinant of the matrix.

Matrix.getColumn(matrix, colIndex)
Arguments:
  • matrix (Matrix)

  • colIndex (int)

Return type:

Matrix

Returns one or multiple columns of the matrix. The columns are returned as a MxK matrix, where M is the number of rows of the original matrix and K is the number of column indices in colIndex.

Matrix.getRow(matrix, rowIndex)
Arguments:
  • matrix (Matrix)

  • rowIndex (int)

Return type:

Matrix

Returns one or multiple rows of the matrix. The rows are returned as a KxN matrix, where N is the number of columns of the original matrix and K is the number of row indices in rowIndex.

Matrix.getSize(matrix)
Argument:
Return type:

int

Returns the number of rows and columns of the matrix.

Matrix.getValue(matrix, rowIndex, colIndex)
Arguments:
  • matrix (Matrix)

  • rowIndex (int)

  • colIndex (int)

Return type:

float

Returns the value of the indexed matrix element. The first element has index (0,0).

Matrix.invert(matrix)
Argument:
Return type:

Matrix

Returns the inverse matrix.

Matrix.max(matrix)
Argument:
Return type:

float

Returns the maximum value of the matrix.

Matrix.min(matrix)
Argument:
Return type:

float

Returns the minimum value of the matrix.

Matrix.multiply(m1, m2)
Arguments:
Return type:

Matrix

Multiplies two matrices. The first matrix must have the same number of columns as the second matrix has rows.

Matrix.multiplyConstant(matrix, value)
Arguments:
  • matrix (Matrix)

  • value (float)

Multiplies each matrix element with the value.

Matrix.norm(matrix)
Argument:
Return type:

float

Returns the Frobenius norm of the matrix, the square root of the sum of the squares of its elements.

Matrix.setAll(matrix, value)
Arguments:
  • matrix (Matrix)

  • value (float)

Sets the whole matrix to the same value.

Matrix.setColumn(matrix, colIndex, newColumn)
Arguments:
Return type:

boolean

Sets one or multiple columns of the matrix.

Matrix.setRow(matrix, rowIndex, newRow)
Arguments:
Return type:

boolean

Sets one or multiple rows of the matrix.

Matrix.setValue(matrix, rowIndex, colIndex, value)
Arguments:
  • matrix (Matrix)

  • rowIndex (int)

  • colIndex (int)

  • value (float)

Sets the value in the indexed matrix element. The first element has index (0,0).

Matrix.solve(a, b)
Arguments:
Return type:

Matrix

Computes the least squares solution to the equation system Ax = b. A is an NxM matrix. b is an Nx1 matrix. x is an Mx1 matrix and the solution to the equation system.

Matrix.subtract(m1, m2)
Arguments:
Return type:

Matrix

Subtracts two matrices of the same size.

Matrix.sumColumns(matrix)
Argument:
Return type:

Matrix

Computes the sum of each column. The column sums are returned as a 1xN row matrix.

Matrix.sumRows(matrix)
Argument:
Return type:

Matrix

Computes the sum of each row. The row sums are returned as a Mx1 column matrix.

Matrix.svd(matrix)
Argument:
Return type:

Matrix

Computes the singular value decomposition of an NxM matrix. U is the left singular vectors and U the right singular vectors corresponding to singular values S. In both U and V vectors are in the columns of each matrix such that matrix = U*diag(S)*V^T.

Matrix.tile(matrix, n, m)
Arguments:
  • matrix (Matrix)

  • n (int)

  • m (int)

Return type:

Matrix

Returns an n-by-m tiling of the matrix.

Matrix.toImage(matrix)
Argument:
Return type:

Image

Converts a matrix to a float64 image.

Matrix.toPoints(matrix, storedInColumns)
Arguments:
  • matrix (Matrix)

  • storedInColumns (boolean)

Return type:

Point

Converts a matrix to a vector of 2D or 3D points.

Matrix.toString(matrix)
Argument:
Return type:

string

Get a string representation of the matrix.

Matrix.toVector(matrix)
Argument:
Return type:

float

Returns all elements of the matrix as vector in row-major order.

Matrix.transpose(matrix)
Argument:
Return type:

Matrix

Returns the transposed matrix.